<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  
    
      
    

    
  

  
    
      
    

    
  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic|Roboto:300,300italic,400,400italic,700,700italic|Georgia:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="用Jekyll搭建博客,jekyll github,jekyll Coding," />





  <link rel="alternate" href="https://www.leolan.top/atom.xml" title="LeoLan's Blog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/200.png?v=5.1.0" />






<meta name="description" content="安装JekyllJekyll用Ruby写的，jekyll是把原文上传github，可以直接生成博客，也可以用在线编辑器处理。

搭建ruby环境（ruby版本最好大于2.2.2），详见：Ruby开发环境搭建  
安装kramdown（Markdown文档处理器）gem install kramdown
安装rouge（语法高亮）gem install rouge
动态处理插件execgem i">
<meta property="og:type" content="article">
<meta property="og:title" content="用Jekyll搭建博客">
<meta property="og:url" content="https://www.leolan.top/posts/56436/index.html">
<meta property="og:site_name" content="LeoLan's Blog">
<meta property="og:description" content="安装JekyllJekyll用Ruby写的，jekyll是把原文上传github，可以直接生成博客，也可以用在线编辑器处理。

搭建ruby环境（ruby版本最好大于2.2.2），详见：Ruby开发环境搭建  
安装kramdown（Markdown文档处理器）gem install kramdown
安装rouge（语法高亮）gem install rouge
动态处理插件execgem i">
<meta property="og:image" content="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A201.png">
<meta property="og:image" content="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A202.png">
<meta property="og:image" content="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A203.png">
<meta property="og:image" content="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A204.png">
<meta property="og:image" content="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A205.png">
<meta property="og:image" content="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A206.png">
<meta property="og:image" content="http://ofyfogrgx.bkt.clouddn.com//blog/%E5%9F%9F%E5%90%8D%E7%BB%91%E5%AE%9A.png">
<meta property="og:updated_time" content="2016-12-07T12:35:12.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="用Jekyll搭建博客">
<meta name="twitter:description" content="安装JekyllJekyll用Ruby写的，jekyll是把原文上传github，可以直接生成博客，也可以用在线编辑器处理。

搭建ruby环境（ruby版本最好大于2.2.2），详见：Ruby开发环境搭建  
安装kramdown（Markdown文档处理器）gem install kramdown
安装rouge（语法高亮）gem install rouge
动态处理插件execgem i">
<meta name="twitter:image" content="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A201.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '6343395544286627000',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: "",
      labels: ""
    }
  };
</script>



  <link rel="canonical" href="https://www.leolan.top/posts/56436/"/>





  <title> 用Jekyll搭建博客 | LeoLan's Blog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">LeoLan's Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">有时候正是不报期望的人做出了人们不敢期望之事！</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签云
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            时间轴
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-guestbook">
          <a href="/guestbook" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-commenting"></i> <br />
            
            给我留言
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            本地搜索
          </a>
        </li>
               
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
  <link itemprop="mainEntityOfPage" href="https://www.leolan.top/posts/56436/">

  <span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="name" content="LeoLan">
    <meta itemprop="description" content="">
    <meta itemprop="image" content="/images/avatar.jpg">
  </span>

  <span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="LeoLan's Blog">
    <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject">
      <img style="display:none;" itemprop="url image" alt="LeoLan's Blog" src="">
    </span>
  </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                用Jekyll搭建博客
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time title="Post created" itemprop="dateCreated datePublished" datetime="2016-11-08T15:13:11+08:00">
              2016-11-08
            </time>

            &nbsp;|&nbsp;

            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-check-o"></i>
            </span>
            <time title="Post modified" itemprop="dateModified" datetime="2016-12-07T20:35:12+08:00">
              2016-12-07
            </time>
            
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/环境搭建/" itemprop="url" rel="index">
                    <span itemprop="name">环境搭建</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/posts/56436/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="posts/56436/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          

          
          
             <span id="/posts/56436/" class="leancloud_visitors" data-flag-title="用Jekyll搭建博客">
               &nbsp; | &nbsp;
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               <span class="post-meta-item-text">阅读次数 </span>
               <span class="leancloud-visitors-count"></span>
              </span>
          

         <span class="post-time">
     &nbsp; | &nbsp;
           <span class="post-meta-item-icon">
             <i class="fa fa-calendar-o"></i>
           </span>
           <span class="post-meta-item-text">字数统计:</span>
           <span class="post-count">3,497(字)</span>
           
         </span>


          
          
          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <script src="/assets/js/DPlayer.min.js"> </script><script src="/assets/js/APlayer.min.js"> </script><h1 id="安装Jekyll"><a href="#安装Jekyll" class="headerlink" title="安装Jekyll"></a>安装Jekyll</h1><p>Jekyll用Ruby写的，jekyll是把原文上传github，可以直接生成博客，也可以用在线编辑器处理。</p>
<ol>
<li>搭建ruby环境（ruby版本最好大于2.2.2），详见：<a href="http://leolan.top/2016/10/31/%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA-2016-10-21-Ruby%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA/" target="_blank" rel="external">Ruby开发环境搭建</a>  </li>
<li>安装kramdown（Markdown文档处理器）<br>gem install kramdown</li>
<li>安装rouge（语法高亮）<br>gem install rouge</li>
<li>动态处理插件exec<br>gem install execjs</li>
<li>安装ruby工具集管理工具Bundler<br>gem install bundler</li>
<li>安装rails WEB框架（可选，不安装运行jekyll时可能报错）<br>gem install rails<br>7.安装Jekyll（“Mac的安装见错误解决”）<br>gem install jekyll</li>
</ol>
<p>之后需要添加功能，要安装其他gems插件时，进入该项目目录再安装，不然不会被包含，就不会生效。<br>错误解决：<br><strong>Mac</strong>：</p>
<figure class="highlight dts"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">mkdir -p <span class="meta-keyword">/usr/</span>local/Cellar<span class="meta-keyword">/ruby/</span>bin</div><div class="line">sudo gem install jekyll -n <span class="meta-keyword">/usr/</span>local/Cellar<span class="meta-keyword">/ruby/</span>bin</div></pre></td></tr></table></figure>
<p>关闭终端窗口再打开，输入<strong>jekyll</strong>看这个指令是否存在，如果提示不存在，那就再修改<br><code>/Users/用户名/.bash_profile</code>文件，把Jekyll的路径写进去。<br><code>export PATH=/usr/local/Cellar/ruby/bin:$PATH</code>再重新打开终端，这时候Jekyll指令应该ok了。<br>注：<code>whereis gem</code>可以看到路径是<strong>/usr/bin/gem</strong>,当前的gem路径是<strong>系统默认的gem版本</strong>，这个版本用了是会报错的，用这个版本安装Jekyll默认安装Jekyll到相同目录下，所以同样会出现permission denied的报错信息。有人说可以用symlink，但即使用了sudo也会是permission denied的报错。所以直接安装Jekyll并同时指定安装路径了。</p>
<p><strong>Windows</strong>：<br>如果安装jekyll或bundle报错，则需要安装编译工具。<br><img src="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A201.png" alt=""><br>打开：<a href="http://rubyinstaller.org/downloads/" target="_blank" rel="external">http://rubyinstaller.org/downloads/</a>  下载对应的<strong>DevKit-mingw</strong>，解压到没有中文、空格、特殊符号的文件夹，</p>
<ol>
<li>cmd进入该目录</li>
<li>命令行下运行<code>ruby dk.rb init</code></li>
<li>编辑目录下的<strong>config.yml</strong>文件 最尾加上<code>- C:\Ruby23-x64  #即ruby安装目录</code><br><img src="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A202.png" alt=""></li>
<li>运行<code>ruby dk.rb review   #（可选，一般不用运行）</code></li>
<li>运行<code>ruby dk.rb install</code></li>
<li>如果上述步骤<strong>只有info输出</strong>而<strong>没有warning输出</strong>，则应该安装成功了</li>
<li>测试<code>gem install json --platform=ruby</code>如果安装成功，则表示devkit安装成功。</li>
<li>如果失败，可以重装ruby和ruby-devkit，或者选择2.0.0以上版本的ruby版本，或<a href="https://rubygems.org/pages/download" target="_blank" rel="external">https://rubygems.org/pages/download</a> 按提示更新gem版本。</li>
</ol>
<p>ok,安装完成啦！</p>
<hr>
<h1 id="建立站点"><a href="#建立站点" class="headerlink" title="建立站点"></a>建立站点</h1><figure class="highlight smali"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">jekyll<span class="built_in"> new </span>new-site   <span class="comment">#创建新站点</span></div><div class="line">cd<span class="built_in"> new-site </span>          <span class="comment">#进入站点目录下一步才能开启服务</span></div><div class="line">jekyll serve --watch  <span class="comment">#加--watch参数修改后会自动刷新页面，而不用手动重启jekyll</span></div><div class="line">jekyll build          <span class="comment">#写了新文章后，编译文档</span></div></pre></td></tr></table></figure>
<p>然后访问localhost:4000就能看到blog的页面了。</p>
<p>注：运行报<strong>Could not find a JavaScript runtime.</strong>错误<br>答：在<strong>gemfile</strong>中加入<br><figure class="highlight nginx"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="attribute">gem</span> <span class="string">'execjs'</span>  </div><div class="line">gem <span class="string">'therubyracer'</span></div></pre></td></tr></table></figure></p>
<p>然后安装<code>gem install therubyracer</code> 再运行就好了。</p>
<p>一个基本的 Jekyll 网站的目录结构一般是像这样的：</p>
<figure class="highlight 1c"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line">├── _config.yml  <span class="meta">#配置文件 </span></div><div class="line">├── _drafts      <span class="meta">#草稿目录</span></div><div class="line"><span class="string">| ├── begin-with-the-crazy-ideas.textile</span></div><div class="line"><span class="string">| └── on-simplicity-in-technology.markdown</span></div><div class="line">├── _includes    <span class="meta">#你可以加载这些包含部分到你的布局或者文章中以方便重用。可以用这个标签 &#123;\% include file.ext \%&#125; 来把文件 _includes/file.ext 包含进来。</span></div><div class="line"><span class="string">| ├── footer.html  #HTML尾</span></div><div class="line"><span class="string">| └── header.html  #HTML头</span></div><div class="line">├── _layouts</div><div class="line"><span class="string">| ├── default.html #默认模板</span></div><div class="line"><span class="string">| └── post.html    #文章模板</span></div><div class="line">├── _posts         <span class="meta">#文章目录</span></div><div class="line"><span class="string">| ├── XXXX.md</span></div><div class="line"><span class="string">| └── XXXXXX.md</span></div><div class="line">├── _data</div><div class="line"><span class="string">| └── members.yml</span></div><div class="line">├── _site         <span class="meta">#生成的站点文件存放目录</span></div><div class="line">└── index.html    <span class="meta">#入口index文件</span></div><div class="line">└──Other Files/Folders   <span class="meta">#其他一些未被提及的目录和文件如 css 还有 images 文件夹， favicon.ico 等文件都将被完全拷贝到生成的 site 中。</span></div></pre></td></tr></table></figure>
<p>安装完成后，如果你要配置你自己的站点信息，那么你就要修改<strong>_config.yml</strong>这个文件。里面可以配置站点名称，描述，多说，统计，友链等等。<br>参考：<br><a href="http://jekyll.com.cn/" target="_blank" rel="external">http://jekyll.com.cn/</a>   中文官网<br><a href="http://pwnny.cn/original/2016/06/26/MakeBlog.html" target="_blank" rel="external">http://pwnny.cn/original/2016/06/26/MakeBlog.html</a></p>
<p>写文章在_posts里，文件名按<strong>YEAR-MONTH-DAY-title.md</strong>创建文件，<br>在文章头部添加YAML头信息（YAML front- matter）：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line"><span class="meta">---</span></div><div class="line"><span class="attr">layout:</span> post</div><div class="line"><span class="attr">title:</span>  <span class="string">"第一篇博客"</span></div><div class="line"><span class="attr">date:</span>   <span class="number">2016</span>/<span class="number">10</span>/<span class="number">26</span> <span class="number">13</span>:<span class="number">03</span>:<span class="number">42</span></div><div class="line"><span class="attr">categories:</span> 文章阅读</div><div class="line"><span class="attr">tag:</span> 第一篇博客,jekyll搭建博客</div><div class="line"><span class="meta">---</span></div><div class="line"></div><div class="line">这里开始用Markdown的语法编写文章。</div></pre></td></tr></table></figure>
<p>每次都自己写yml文件头太麻烦，配置中会说到用Rakefile脚本自动生成文件。<strong>注意：yml文件头不要有中文，.md文件名也不要有中文，</strong>否则网页会显示404错误（原因未知）</p>
<hr>
<h1 id="配置优化、美化站点"><a href="#配置优化、美化站点" class="headerlink" title="配置优化、美化站点"></a>配置优化、美化站点</h1><h2 id="主题部分"><a href="#主题部分" class="headerlink" title="主题部分"></a>主题部分</h2><p>可以在<a href="http://jekyllthemes.org/这个上面找找，Hux这个主题还是不错的，喜欢的直接下载，重新修改里面配置就行了。可以fork或下载回来，整个替换，把文章拷过去就行。一个很好的Hux模板：https://github.com/huxpro/huxpro.github.io/" target="_blank" rel="external">http://jekyllthemes.org/这个上面找找，Hux这个主题还是不错的，喜欢的直接下载，重新修改里面配置就行了。可以fork或下载回来，整个替换，把文章拷过去就行。一个很好的Hux模板：https://github.com/huxpro/huxpro.github.io/</a></p>
<h2 id="配置文件设置"><a href="#配置文件设置" class="headerlink" title="配置文件设置"></a>配置文件设置</h2><p>我用到的参数：<br><figure class="highlight elixir"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div></pre></td><td class="code"><pre><div class="line"><span class="comment">#不要在配置文件中使用 tab 制表符,用空格代替。</span></div><div class="line"><span class="comment">#配置请参考：http://jekyllcn.com/docs/configuration/#front-matter-defaults</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment"># Site settings</span></div><div class="line"><span class="symbol">title:</span> LeoLan的博客</div><div class="line"><span class="symbol">author:</span> Leo Lan</div><div class="line"><span class="symbol">email:</span> <span class="number">842632422</span><span class="variable">@qq</span>.com</div><div class="line"><span class="symbol">description:</span> &gt; <span class="comment"># this means to ignore newlines until "baseurl:"</span></div><div class="line">  Write an awesome description <span class="keyword">for</span> your new site here. You can edit this</div><div class="line">  line <span class="keyword">in</span> _config.yml. It will appear <span class="keyword">in</span> your document head meta (<span class="keyword">for</span></div><div class="line">  Google search results) <span class="keyword">and</span> <span class="keyword">in</span> your feed.xml site description.</div><div class="line"></div><div class="line"><span class="comment">#自定义站点标题</span></div><div class="line"><span class="comment">#webrick:</span></div><div class="line"><span class="comment">#  headers:</span></div><div class="line"><span class="comment">#    My-Header: My-Value</span></div><div class="line"><span class="comment">#    My-Other-Header: My-Other-Value</span></div><div class="line"></div><div class="line"></div><div class="line"><span class="comment"># Site URL <span class="doctag">NOTE:</span> if your site is base on subdir /blog you should change base to "/blog"</span></div><div class="line"><span class="symbol">domain:</span> <span class="string">"http://myleolan.github.io"</span> <span class="comment">#你的github网址  the domain URL for your site</span></div><div class="line"><span class="symbol">base:</span> <span class="string">""</span>  <span class="comment"># the relative path that different with domain so you can test locally</span></div><div class="line"></div><div class="line"><span class="comment"># Source URL <span class="doctag">NOTE:</span> end with / cause it's [URL + FILE]</span></div><div class="line"><span class="symbol">w3c_url:</span> <span class="string">"/w3c/"</span>  <span class="comment"># the base url of css js and images</span></div><div class="line"><span class="symbol">postImage_url:</span> <span class="string">"/w3c/images/"</span> <span class="comment"># the base url of post images</span></div><div class="line"><span class="symbol">postfile:</span> <span class="string">"/db/Postfile"</span> <span class="comment"># the Database</span></div><div class="line"><span class="symbol">sitefile:</span> <span class="string">"/db/Sitefile"</span> <span class="comment"># the Database</span></div><div class="line"></div><div class="line"><span class="comment"># 3rd URL</span></div><div class="line"><span class="symbol">duoshuo_short_name:</span> <span class="string">"leolan"</span> <span class="comment"># 注册多说是填写的网址前缀 the user of user.domain.com </span></div><div class="line"><span class="symbol">duoshuo_user_uid:</span> <span class="string">"a61c3f290749b621688a3f42c7e8e31c"</span> <span class="comment">#多说的uid   the admin user uid  </span></div><div class="line"><span class="symbol">duoshuo_user_name:</span> <span class="string">"leolan"</span> <span class="comment">#多说的用户名 the admin user names   </span></div><div class="line"><span class="symbol">duoshuo_max_depth:</span> <span class="string">"2"</span>  <span class="comment"># the max_depth setting in duoshuo comments</span></div><div class="line"><span class="symbol">duoshuo_url:</span> <span class="string">"/w3c/duoshuo/embed.min.js"</span> <span class="comment"># the local duoshuo comment plugin, you can change it to remote "http://static.duoshuo.com/"</span></div><div class="line"><span class="symbol">jquery_url:</span> <span class="string">"http://cdn.bootcss.com/jquery/3.1.0/jquery.min.js"</span> <span class="comment"># use cdn</span></div><div class="line"><span class="symbol">baiduTemplate_url:</span> <span class="string">"/w3c/js/baiduTemplate.js"</span> <span class="comment">#use local</span></div><div class="line"><span class="symbol">google_analytics_id:</span> <span class="string">"UA-86334360-1"</span>  <span class="comment">#Google分析</span></div><div class="line"></div><div class="line"><span class="comment"># Build Settings</span></div><div class="line"><span class="symbol">excerpt_separator:</span> <span class="string">"\n\n"</span> <span class="comment"># you can specify your own separator here, default is "\n\n" String</span></div><div class="line"><span class="symbol">permalink:</span> /<span class="symbol">:year/</span><span class="symbol">:month/</span><span class="symbol">:day/</span><span class="symbol">:title</span>.html   <span class="comment">#生成html文件的命名方式</span></div><div class="line"><span class="symbol">highlighter:</span> rouge   <span class="comment">#代码高亮</span></div><div class="line"><span class="symbol">markdown:</span> kramdown   <span class="comment">#markdown文档处理器</span></div><div class="line"><span class="symbol">kramdown:</span></div><div class="line">  <span class="symbol">input:</span> GFM</div><div class="line">  <span class="symbol">hard_wrap:</span> <span class="keyword">true</span> <span class="comment"># a newline in markdown text would be changed to &lt;br&gt;</span></div><div class="line"></div><div class="line"><span class="comment">#插件（需要包含的插件）</span></div><div class="line"><span class="symbol">gems:</span></div><div class="line">  - jemoji</div><div class="line"></div><div class="line"><span class="symbol">lsi:</span> BOOL   <span class="comment">#建立文件索引</span></div><div class="line"></div><div class="line"><span class="comment">####---------------------------------------------------------------------</span></div><div class="line"><span class="comment">#以下为github的默认设置</span></div><div class="line"></div><div class="line"><span class="comment"># Following is got in Github Help With Configuring Jekyll</span></div><div class="line"><span class="comment"># Github Page Default Settings which you can override:</span></div><div class="line"></div><div class="line"><span class="comment"># kramdown:</span></div><div class="line"><span class="comment">#   input: GFM</span></div><div class="line"><span class="comment">#   hard_wrap: false</span></div><div class="line"><span class="comment"># gems:</span></div><div class="line"><span class="comment">#   - jekyll-coffeescript</span></div><div class="line"><span class="comment">#   - jekyll-paginate</span></div><div class="line"></div><div class="line"><span class="comment"># Github Page override the following settings which you cannot change:</span></div><div class="line"><span class="comment"># lsi: false</span></div><div class="line"><span class="comment"># safe: true    #安全方式，禁用所有插件</span></div><div class="line"><span class="comment"># source: [your repo's top level directory]</span></div><div class="line"><span class="comment"># incremental: false</span></div><div class="line"><span class="comment"># highlighter: rouge</span></div><div class="line"><span class="comment"># gist:</span></div><div class="line"><span class="comment">#  noscript: false</span></div><div class="line"><span class="comment"># kramdown:</span></div><div class="line"><span class="comment">#  math_engine: mathjax</span></div></pre></td></tr></table></figure></p>
<h2 id="自动生成文件模板"><a href="#自动生成文件模板" class="headerlink" title="自动生成文件模板"></a>自动生成文件模板</h2><p>前面说到的带yml信息的文件头<br><figure class="highlight yaml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="meta">---</span></div><div class="line"><span class="attr">layout:</span> post</div><div class="line"><span class="attr">title:</span>  <span class="string">"第一篇博客"</span></div><div class="line"><span class="attr">date:</span>   <span class="number">2016</span>/<span class="number">10</span>/<span class="number">26</span> <span class="number">13</span>:<span class="number">03</span>:<span class="number">42</span></div><div class="line"><span class="attr">categories:</span> 文章阅读</div><div class="line"><span class="attr">tag:</span> 第一篇博客,jekyll搭建博客</div><div class="line"><span class="meta">---</span></div></pre></td></tr></table></figure></p>
<p>文件头可以自动生成，而不用每次都手工码字，在网站根目录下创建Rakefile文件（ruby的一中脚本配置文件）<br>里面填入代码：</p>
<figure class="highlight ruby"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div></pre></td><td class="code"><pre><div class="line">task <span class="symbol">:default</span> =&gt; <span class="symbol">:new</span></div><div class="line"></div><div class="line"><span class="keyword">require</span> <span class="string">'fileutils'</span></div><div class="line"></div><div class="line">desc <span class="string">"创建新 post"</span></div><div class="line">task <span class="symbol">:new</span> <span class="keyword">do</span></div><div class="line">  puts <span class="string">"请输入要创建的.md文件名："</span></div><div class="line">  @url = STDIN.gets.chomp</div><div class="line">  puts <span class="string">"请输入 文章 标题："</span></div><div class="line">  @name = STDIN.gets.chomp</div><div class="line">  puts <span class="string">"请输入 文章 子标题："</span></div><div class="line">  @subtitle = STDIN.gets.chomp</div><div class="line">  puts <span class="string">"请输入 文章 分类，以空格分隔："</span></div><div class="line">  @categories = STDIN.gets.chomp</div><div class="line">  puts <span class="string">"请输入 博客分类 标签，以空格分隔："</span></div><div class="line">  @tag = STDIN.gets.chomp</div><div class="line">  @slug = <span class="string">"<span class="subst">#&#123;@url&#125;</span>"</span></div><div class="line">  @slug = @slug.downcase.strip.gsub(<span class="string">' '</span>, <span class="string">'-'</span>)</div><div class="line">  @date = Time.now.strftime(<span class="string">"%F"</span>)</div><div class="line">  @post_name = <span class="string">"_posts/<span class="subst">#&#123;@date&#125;</span>-<span class="subst">#&#123;@slug&#125;</span>.md"</span></div><div class="line">  <span class="keyword">if</span> File.exist?(@post_name)</div><div class="line">      abort(<span class="string">"文件名已经存在！创建失败"</span>)</div><div class="line">  <span class="keyword">end</span></div><div class="line">  FileUtils.touch(@post_name)</div><div class="line">  open(@post_name, <span class="string">'a'</span>) <span class="keyword">do</span> <span class="params">|file|</span></div><div class="line">      file.puts <span class="string">"---"</span></div><div class="line">      file.puts <span class="string">"layout: post"</span></div><div class="line">      file.puts <span class="string">"title: <span class="subst">#&#123;@name&#125;</span>"</span></div><div class="line">      file.puts <span class="string">"subtitle: <span class="subst">#&#123;@subtitle&#125;</span>"</span></div><div class="line">      file.puts <span class="string">"author: Leo Lan"</span></div><div class="line">      file.puts <span class="string">"date: <span class="subst">#&#123;Time.now&#125;</span>"</span></div><div class="line">      file.puts <span class="string">"categories: <span class="subst">#&#123;@categories&#125;</span>"</span></div><div class="line">      file.puts <span class="string">"tag: <span class="subst">#&#123;@tag&#125;</span>"</span></div><div class="line">      file.puts <span class="string">"published: true"</span></div><div class="line">      file.puts <span class="string">"---"</span></div><div class="line">  <span class="keyword">end</span></div><div class="line">  exec <span class="string">"vim <span class="subst">#&#123;@post_name&#125;</span>"</span></div><div class="line"><span class="keyword">end</span></div></pre></td></tr></table></figure>
<p><strong>layout</strong>表示使用的是post布局，title是文章标题，<br><strong>date</strong>是自动生成的日期，<br><strong>subtitle</strong>是副标题<br><strong>categories</strong>是该文章生成html文件后存放的目录（分类），可以去_site/jekyll/update下找到对应日期下面的html文档。当然你也可以只设置jekyll单一的目录，甚至是更多级别的目录，用空格分开即可。<strong>tag</strong>是文章的标签。<br><strong>published</strong>表示是否发布文章<br>下次在命令行输入<code>rake new</code>按提示一步一步就能创建一个很好的文件啦，剩下的只需要专心写作就好了。</p>
<p>参考：<a href="http://www.liubaicai.net/articles/733/" target="_blank" rel="external">http://www.liubaicai.net/articles/733/</a></p>
<hr>
<h1 id="用Github-Pages生成个人博客"><a href="#用Github-Pages生成个人博客" class="headerlink" title="用Github Pages生成个人博客"></a>用Github Pages生成个人博客</h1><p>Github Pages生成网站的两种方式的基本原理</p>
<h2 id="法一："><a href="#法一：" class="headerlink" title="法一："></a>法一：</h2><p>在Github上有一个账号，名为 username （任意），有一个项目，名为 username.github.io （固定格式，username与账号名一致），项目分支名为 <strong>master</strong> （默认固定），这个分支有类似下面的目录结构：<br><img src="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A203.png" alt=""><br>当你访问 <a href="http://username.github.io/" target="_blank" rel="external">http://username.github.io/</a> 时，Github会使用Jekyll解析用户 username 名下的 username.github.io 项目中，分支为 master 的源代码，为你构建一个静态网站，并将生成的 index.html 展示给你。</p>
<h2 id="法二："><a href="#法二：" class="headerlink" title="法二："></a>法二：</h2><p>在Github上有一个账号，名为 username （任意），有一个项目，名为 blog （任意），项目分支名为 <strong>gh-pages </strong>（固定），这个分支也有上面那种结构。<br>那么当你访问 <a href="http://username.github.io/blog" target="_blank" rel="external">http://username.github.io/blog</a> 时，Github会去解析 username 用户下，project 项目的 gh-pages 分支下的源代码，为你构建网站。</p>
<p>所以要搭建自己的博客你有两种选择：</p>
<ul>
<li>建立名为 username.github.io 的项目，在 master 分支下存放网站源代码</li>
<li>建立名为 blog 的项目，在 gh-pages 分支下存放网站源代码<br>考虑到第一种项目名复杂不方便同步等，这里用第二种方法，方便管理。<br>新建一个仓库，名称随意，ReadMe.md文件随意，不懂的查看教程第4节“创建远程仓库”：<a href="https://www.leolan.top/posts/41310/">git教程</a></li>
</ul>
<p><img src="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A204.png" alt=""><br>翻到下面，选择<strong>Launch automatic page generator</strong><br><img src="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A205.png" alt=""><br>再接着编译一下内容，点<strong>Continue to layouts</strong><br>选好模板，点击<strong>Publish page</strong>，就生成了Github Pages，并且，分支自动设置为了gh-pages。<br><img src="http://ofyfogrgx.bkt.clouddn.com//blog/%E7%94%A8Jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A206.png" alt=""></p>
<p>打开网站看看效果：<a href="https://myleolan.github.io/blog/" target="_blank" rel="external">https://myleolan.github.io/blog/</a><br>以后本地写好的文章，jekyll bundle之后就可以推送到gh-pages分支即可。推送博客到github推荐用命令行，Windows版的客户端不熟悉容易误操作。 博客源码和发布的博客网页在同一个仓库中，可以共同存放。（Hexo是生成的网站和博客原文分开存放的）</p>
<h1 id="Github-Pages环境本地化"><a href="#Github-Pages环境本地化" class="headerlink" title="Github Pages环境本地化"></a>Github Pages环境本地化</h1><p>上面搭建的只是Jekyll的本地环境，当push到Github Pages后环境会有所变化，为了本地看到的效果和托管在Github Pages看到的效果一致，我们最好搭建本地的Github Pages环境。<br>ruby要2.0.0以上版本，如果<code>ruby --version</code>查看版本低于2.0.0，那么需要升级ruby。<br>安装ruby工具集管理工具Bundler （前面安装过了就不用安装了）<br><figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">gem <span class="keyword">install </span><span class="keyword">bundler</span></div><div class="line"><span class="keyword">bundler </span>-v</div></pre></td></tr></table></figure></p>
<p>进入jekyll创建的网站目录<br><figure class="highlight mipsasm"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">git init                      <span class="comment">#把当前目录加入版本库中</span></div><div class="line">git checkout -<span class="keyword">b </span>gh-pages      <span class="comment">#创建gh-pages分支，用于推送到github上的gh-pages分支上。</span></div></pre></td></tr></table></figure></p>
<p>创建<strong>Gemfile</strong>文件 如果本生有Gemfile和Gemfile.lock那就删除掉，内容如下：<br><figure class="highlight axapta"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">source <span class="string">'https://ruby.taobao.org'</span>  <span class="meta">#(淘宝源，国内比较快)</span></div><div class="line">gem <span class="string">'github-pages'</span>, <span class="keyword">group</span>: :jekyll_plugins</div><div class="line">或</div><div class="line">source <span class="string">'https://rubygems.org'</span>   <span class="meta">#(官方源)</span></div><div class="line">gem <span class="string">'github-pages'</span>, <span class="keyword">group</span>: :jekyll_plugins</div></pre></td></tr></table></figure></p>
<p>执行下面的命令安装Github Pages的工具集<strong>（在网站根目录，就是Gemfile文件的路径）</strong><br><code>bundle install</code><br>运行起来（一开始创建了网站就可以直接跑起来啦，如果没有创建网站，创建或fork别人的。）<br><code>bundle exec jekyll serve</code></p>
<p>如果出现<strong>bundle exec jekyll serve</strong>能启动，而<strong>jekyll serve</strong>不能启动，则删除Gemfile和Gemfile.lock重新运行jekyll serve即可。<br>更多Github Pages本地化环境搭建，可参考官方文档:<a href="https://help.github.com/articles/setting-up-your-github-pages-site-locally-with-jekyll/" target="_blank" rel="external">https://help.github.com/articles/setting-up-your-github-pages-site-locally-with-jekyll/</a></p>
<p>注意：如果是是下载了别人的模板进行修改，只把文件拷到自己项目中进行添加就可以了，不要全选把<strong>.git</strong>文件夹也拷过了，别人的分支和自己的不同时会出现各种问题。</p>
<p>调试好各种东西后就可以推送到Github了。</p>
<ol>
<li>用markdown写文章，并按规定名称格式保存在_posts里。</li>
<li>用<code>jekyll serve –watch</code>或<code>bundle exec jekyll server</code>启动服务器，在浏览器里查看。(指定端口在<strong>_config.yml</strong>文件中增加<code>port: xxxx</code>)</li>
<li>用git客户端推送到远程仓库里。</li>
<li>通过域名访问。</li>
</ol>
<hr>
<h1 id="绑定域名"><a href="#绑定域名" class="headerlink" title="绑定域名"></a>绑定域名</h1><p>原理是域名提供商的域名指向github或coding的域名服务器，在项目内建立CNAME的域名指向文件后，会自动去自己的域名服务器github或coding上查找该域名，找到啦就绑定在一起，找不到就绑定不了；如果绑定不了，那么域名指向的github和coding（Pages绑定域名时）服务器会报404错误；域名指向的coding（Pages页面没有绑定域名时）域名服务器会把index当做普通超文本解析，不会加载js、cs等资源。</p>
<ul>
<li>1· 在你的项目下新建一个<strong>CNAME</strong>文件，注意没有后缀名。在里面添加你的域名，一行一个，如我的就是<strong> www.leolan.top</strong>和<strong> leolan.top</strong>（github会自动绑定第一个，第二个也要绑定，不绑定访问报404错误），然后推送<strong>CNAME文件</strong>到远程仓库。（Github不建议在pages页上绑定设置，页面上是只能绑定一个的）；Coding的话要在<strong>CNAME文件</strong>里绑定两个，在Pages页面也绑定两个。</li>
<li>2· 到域名服务商那里增加你的CNAME记录。添加两条记录，@和www的主机记录，记录类型为CNAME，记录值为 <code>username.github.io.</code>，重要的是 io 后面还有一个原点（看官方帮助文档Coding的就不用加点），切记。<br><img src="http://ofyfogrgx.bkt.clouddn.com//blog/%E5%9F%9F%E5%90%8D%E7%BB%91%E5%AE%9A.png" alt=""><br>过几分钟，刷新网页，就能直接用域名访问了，因为是在项目内建的<strong>CNAME</strong>文件，所以域名直接指向此项目文件夹，其他项目可以用其他域名设定。</li>
</ul>
<hr>

<!--这里是每篇文章的尾巴-->
<html>
  <body>
    <h1>结语</h1>
      <p>如果您觉得本博客还不错，欢迎继续关注本博客，欢迎多提宝贵意见，非常感谢！</p>
      <div style="text-align:center;color:#ccc;font-size:14px;">------本文结束<i class="fa fa-paw"></i>感谢阅读------</div>
  </body>
</html>

<!--
<html>
  <body>
    <h2 id="结语"><a href="#结语" class="headerlink" title="结语"></a>结语</h2>
    <blockquote><p>如果您觉得本博客还不错，欢迎继续关注本博客，欢迎多提宝贵意见，非常感谢！</p></blockquote></div>
    <div style="text-align:center;color:#ccc;font-size:14px;">------本文结束<i class="fa fa-paw"></i>感谢阅读------</div>
  </body>
</html>

<html>
  <body>
    <h2 id="结语"><a href="#结语" class="headerlink" title="结语"></a>结语</h2>
    <blockquote><p>如果您觉得本博客还不错，欢迎收藏书签，欢迎多提宝贵意见，非常感谢！</p>
    <footer><strong>Welcome to LeoLan'S BLOG</strong>
    <cite><a href="#" onclick="go_my_site()" rel="external">Leo Lan Blog Share For you!</a></cite></footer></blockquote></div>
  </body>
</html>
-->
      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
<div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center">
  <div style="margin-bottom: 10px;font-size: 16px;font-weight: 600;">您的支持将鼓励我继续创作,非常感谢！</div>
  <button id="rewardButton", disable="enable", onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}", style="cursor: pointer; border: 0; outline: 0; border-radius: 100%; padding: 0; margin: 0; letter-spacing: normal; text-transform: none; text-indent: 0px; text-shadow: none">
    <span onmouseover="this.style.color='rgb(236,96,0)';this.style.background='rgb(204,204,204)'" onMouseOut="this.style.color='#fff';this.style.background='rgb(236,96,0)'" style="display: inline-block; width: 70px; height: 70px; border-radius: 100%; line-height: 81px; color: #fff; font: 400 35px/75px 'microsofty'; background: rgb(236,96,0)">赏</span>
  </button>
    <div id="QR" style="display: none;">
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="http://ofyfogrgx.bkt.clouddn.com//pay/alipay.jpg" alt="LeoLan Alipay" style="width: 200px; max-width: 100%; display: inline-block"/>
          <p>支付宝打赏</p>
        </div>
      
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="http://ofyfogrgx.bkt.clouddn.com//pay/weixinpay.png" alt="LeoLan WeChat Pay" style="width: 200px; max-width: 100%; display: inline-block"/>
          <p>微信打赏</p>
        </div>
      
    </div>
  </div>


<h3 id="最近访客"><a href="#最近访客" class="headerlink" title="最近访客"></a>最近访客</h3><div class="ds-recent-visitors" data-num-items="28" data-avatar-size="42" id="ds-recent-visitors"></div>
      
    </div>

<!--这是文章底部标签云链接
    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/用Jekyll搭建博客/" rel="tag"># 用Jekyll搭建博客</a>
          
            <a href="/tags/jekyll-github/" rel="tag"># jekyll github</a>
          
            <a href="/tags/jekyll-Coding/" rel="tag"># jekyll Coding</a>
          
        </div>
      
-->
      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/posts/27796/" rel="next" title="Zabbix监控">
                <i class="fa fa-chevron-left"></i> Zabbix监控
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/posts/23632/" rel="prev" title="用Hexo搭建博客">
                用Hexo搭建博客 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        
<script>
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js;
</script>

      
    </div>
  </div>


          </div>
          

  <p>热评文章</p>
  <div class="ds-top-threads" data-range="weekly" data-num-items="4"></div>


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="posts/56436/"
           data-title="用Jekyll搭建博客" data-url="https://www.leolan.top/posts/56436/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.jpg"
               alt="LeoLan" />
          <p class="site-author-name" itemprop="name">LeoLan</p>
          <p class="site-description motion-element" itemprop="description">Better late than never</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">56</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">14</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">80</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="https://www.leolan.top/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>

<!-- 自定义High一下的功能 -->
 <a rel="alternate" class="mw-harlem_shake_slow wobble shake" href='javascript:(
   function go() {
   var songs = [
               "http://ofyfogrgx.bkt.clouddn.com/tongxingSibel%20-%20Im%20Sorry.mp3",
               "http://ofyfogrgx.bkt.clouddn.com/Music-sunburst.mp3",
               "http://ofyfogrgx.bkt.clouddn.com/blog/20161115/150103346.mp3",
               "http://ofyfogrgx.bkt.clouddn.com/blog/20161115/150842689.mp3",
               "http://ofyfogrgx.bkt.clouddn.com//blog/Apple%20&%20Stone%20-%20Lost.mp3"
   ];
   
   function c() {
       var e = document.createElement("link");
       e.setAttribute("type", "text/css");
       e.setAttribute("rel", "stylesheet");
       e.setAttribute("href", f);
       e.setAttribute("class", l);
       document.body.appendChild(e)
   }
   function h() {
       var e = document.getElementsByClassName(l);
       for (var t = 0; t < e.length; t++) {
           document.body.removeChild(e[t])
       }
   }
   function p() {
       var e = document.createElement("div");
       e.setAttribute("class", a);
       document.body.appendChild(e);
       setTimeout(function() {
           document.body.removeChild(e)
       }, 100)
   }
   function d(e) {
       return {
           height : e.offsetHeight,
           width : e.offsetWidth
       }
   }
   function v(i) {
       var s = d(i);
       return s.height > e && s.height < n && s.width > t && s.width < r
   }
   function m(e) {
       var t = e;
       var n = 0;
       while (!!t) {
           n += t.offsetTop;
           t = t.offsetParent
       }
       return n
   }
   function g() {
       var e = document.documentElement;
       if (!!window.innerWidth) {
           return window.innerHeight
       } else if (e && !isNaN(e.clientHeight)) {
           return e.clientHeight
       }
       return 0
   }
   function y() {
       if (window.pageYOffset) {
           return window.pageYOffset
       }
       return Math.max(document.documentElement.scrollTop, document.body.scrollTop)
   }
   function E(e) {
       var t = m(e);
       return t >= w && t <= b + w
   }
   function S() {
       var e = document.getElementById("audio_element_id");
       if(e != null){
           var index = parseInt(e.getAttribute("curSongIndex"));
           if(index > songs.length - 2) {
               index = 0;
           } else {
               index++;
           }
           e.setAttribute("curSongIndex", index);
           N();
       }
       e.src = i;
       e.play()
   }
   function x(e) {
       e.className += " " + s + " " + o
   }
   function T(e) {
       e.className += " " + s + " " + u[Math.floor(Math.random() * u.length)]
   }
   function N() {
       var e = document.getElementsByClassName(s);
       var t = new RegExp("\\b" + s + "\\b");
       for (var n = 0; n < e.length; ) {
           e[n].className = e[n].className.replace(t, "")
       }
   }
   function initAudioEle() {
       var e = document.getElementById("audio_element_id");
       if(e === null){
           e = document.createElement("audio");
           e.setAttribute("class", l);
           e.setAttribute("curSongIndex", 0);
           e.id = "audio_element_id";
           e.loop = false;
           e.bgcolor = 0;
           e.addEventListener("canplay", function() {
           setTimeout(function() {
               x(k)
           }, 500);
           setTimeout(function() {
               N();
               p();
               for (var e = 0; e < O.length; e++) {
                   T(O[e])
               }
           }, 15500)
       }, true);
       e.addEventListener("ended", function() {
           N();
           h();
           go();
       }, true);
       e.innerHTML = " <p>If you are reading this, it is because your browser does not support the audio element. We recommend that you get a new browser.</p> <p>";
       document.body.appendChild(e);
       }
   }
   
   initAudioEle();
   var e = 30;
   var t = 30;
   var n = 350;
   var r = 350;
   var curSongIndex = parseInt(document.getElementById("audio_element_id").getAttribute("curSongIndex"));
   var i = songs[curSongIndex];
   
   var s = "mw-harlem_shake_me";
   var o = "im_first";
   var u = ["im_drunk", "im_baked", "im_trippin", "im_blown"];
   var a = "mw-strobe_light";
   /* harlem-shake-style.css，替换成你的位置，也可以直接使用：//s3.amazonaws.com/moovweb-marketing/playground/harlem-shake-style.css */
   var f = "//7xncbk.com1.z0.glb.clouddn.com/harlem-shake-style.css";  
   /* var f = "/css/harlem_shake_style.css";  */

   var l = "mw_added_css";
   var b = g();
   var w = y();
   var C = document.getElementsByTagName("*");
   var k = null;
   for (var L = 0; L < C.length; L++) {
       var A = C[L];
       if (v(A)) {
           if (E(A)) {
               k = A;
               break
           }
       }
   }
   if (A === null) {
       console.warn("Could not find a node of the right size. Please try a different page.");
       return
   }
   c();
   S();
   var O = [];
   for (var L = 0; L < C.length; L++) {
       var A = C[L];
       if (v(A)) {
           O.push(A)
       }
   }
   })()'><i class="menu-item-icon fa fa-music fa-fw"></i>High</a>
</div>
         <!-- end High一下 -->
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/myleolan" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://coding.net/u/leolan" target="_blank" title="Coding">
                  
                    <i class="fa fa-fw fa-github-alt"></i>
                  
                  Coding
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://quickconnect.to/myleolan" target="_blank" title="Cloud">
                  
                    <i class="fa fa-fw fa-cloud"></i>
                  
                  Cloud
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://git.oschina.net/leolan" target="_blank" title="OSchina">
                  
                    <i class="fa fa-fw fa-git-square"></i>
                  
                  OSchina
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-heartbeat"></i>
              友链
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="https://jerry.hk/" title="Jerry Locke" target="_blank" rel="external nofollow">Jerry Locke</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://login926.top" title="Raintons" target="_blank" rel="external nofollow">Raintons</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.iamlj.com/" title="Jing's Blog" target="_blank" rel="external nofollow">Jing's Blog</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://haiwx.github.io/" title="E-Loli" target="_blank" rel="external nofollow">E-Loli</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://cyang.tech/" title="cyang's blog" target="_blank" rel="external nofollow">cyang's blog</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.anotherhome.net" title="DIYgod" target="_blank" rel="external nofollow">DIYgod</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://lusongsong.com/" title="卢松松的博客" target="_blank" rel="external nofollow">卢松松的博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://v.lusongsong.com/" title="松松视频" target="_blank" rel="external nofollow">松松视频</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://mblack.cn/" title="小黑" target="_blank" rel="external nofollow">小黑</a>
                </li>
              
            </ul>
          </div>
        

        

      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#安装Jekyll"><span class="nav-number">1.</span> <span class="nav-text">安装Jekyll</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#建立站点"><span class="nav-number">2.</span> <span class="nav-text">建立站点</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#配置优化、美化站点"><span class="nav-number">3.</span> <span class="nav-text">配置优化、美化站点</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#主题部分"><span class="nav-number">3.1.</span> <span class="nav-text">主题部分</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置文件设置"><span class="nav-number">3.2.</span> <span class="nav-text">配置文件设置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#自动生成文件模板"><span class="nav-number">3.3.</span> <span class="nav-text">自动生成文件模板</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#用Github-Pages生成个人博客"><span class="nav-number">4.</span> <span class="nav-text">用Github Pages生成个人博客</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#法一："><span class="nav-number">4.1.</span> <span class="nav-text">法一：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#法二："><span class="nav-number">4.2.</span> <span class="nav-text">法二：</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Github-Pages环境本地化"><span class="nav-number">5.</span> <span class="nav-text">Github Pages环境本地化</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#绑定域名"><span class="nav-number">6.</span> <span class="nav-text">绑定域名</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">LeoLan</span>
</div>

<div class="powered-by">
  粤ICP325436-2 | 本站总访问量<span id="busuanzi_value_site_pv"></span>
</div>

<div class="theme-info">
  您是第<span id="busuanzi_value_site_uv"></span>位小伙伴
</div>

<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>


        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"leolan"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '/js/src/duoshuo_embed.js';
      ds.charset = 'UTF-8';
      (document.getElementById('footer')
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
      
      <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
      <script src="/js/src/hook-duoshuo.js?v=5.1.0"></script>
    
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  








  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
      search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();
    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';
      $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = $( "entry", xmlResponse ).map(function() {
            return {
              title: $( "title", this ).text(),
              content: $("content",this).text(),
              url: $( "url" , this).text()
            };
          }).get();
          var $input = document.getElementById(search_id);
          var $resultContent = document.getElementById(content_id);
          $input.addEventListener('input', function(){
            var matchcounts = 0;
            var str='<ul class=\"search-result-list\">';
            var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
            $resultContent.innerHTML = "";
            if (this.value.trim().length > 1) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var content_index = [];
                var data_title = data.title.trim().toLowerCase();
                var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                var data_url = decodeURIComponent(data.url);
                var index_title = -1;
                var index_content = -1;
                var first_occur = -1;
                // only match artiles with not empty titles and contents
                if(data_title != '') {
                  keywords.forEach(function(keyword, i) {
                    index_title = data_title.indexOf(keyword);
                    index_content = data_content.indexOf(keyword);
                    if( index_title >= 0 || index_content >= 0 ){
                      isMatch = true;
                      if (i == 0) {
                        first_occur = index_content;
                      }
                    }

                  });
                }
                // show search results
                if (isMatch) {
                  matchcounts += 1;
                  str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                  var content = data.content.trim().replace(/<[^>]+>/g,"");
                  if (first_occur >= 0) {
                    // cut out 100 characters
                    var start = first_occur - 20;
                    var end = first_occur + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if(start == 0){
                      end = 50;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    var match_content = content.substring(start, end);
                    // highlight all keywords
                    keywords.forEach(function(keyword){
                      var regS = new RegExp(keyword, "gi");
                      match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                    });

                    str += "<p class=\"search-result\">" + match_content +"...</p>"
                  }
                  str += "</li>";
                }
              })};
            str += "</ul>";
            if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
            if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
            $resultContent.innerHTML = str;
          });
          proceedsearch();
        }
      });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("zieuxKa4IjAP6VgxxvBe4vkj-gzGzoHsz", "MHGN54IEuofFNV1AROiRkEoG");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>


  


<!-- 背景动画 -->
<script type="text/javascript" src="/js/src/particle.js" count="50" zindex="-2" opacity="1" color="0,104,183"></script>

</body>
</html>
